package com.turtle3d.user.grammars;

import java.util.ArrayList;

import com.turtle3d.formallanguage.grammar.Grammar;
import com.turtle3d.formallanguage.parser.SimpleParser;
import com.turtle3d.formallanguage.symbol.Method;
import com.turtle3d.formallanguage.symbol.Symbol;
import com.turtle3d.formallanguage.symbol.SymbolClass;
import com.turtle3d.formallanguage.symbol.SymbolFactory;

public class OTitle extends Grammar
{

	@Override
	public void define()
	{
		/*
		 * axiom X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+;
			angle 15;
			X: [F+F+F+F[---X-Y]+++++F++++++++F-F-F-F];
			Y: ;
		 */
		
		setAxiom(SimpleParser.parseSymbolSequence("X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+"));
				
		SymbolClass pitch2 = new SymbolClass("/", "/(pitch2)");		
		pitch2.addMethod(new Method(){
			public boolean calculate(ArrayList<Symbol> symbolSequence, int symbolIndex, Symbol calculatedSymbol)
			{
				calculatedSymbol.setParameter("pitchAngle", calculatedSymbol.getParameter("pitchAngle2"));
				
				return true;
				
			}
		});				
		SymbolFactory.getSymbolFactory().registerSymbolClass(pitch2);
		
		
		addProduction(SimpleParser.parseProduction("X->/>[F+F+F+F[---X-Y]+++++F++++++++F-F-F-F]"));
		addProduction(SimpleParser.parseProduction("Y->/(pitch2)[F+F+F+F[---Y]+++++F++++++++F-F-F-F]"));

	}
	
	public void setRequiredParameters(){
		setRequiredParameter("turnAngle", 15f);
		setRequiredParameter("pitchAngle", 15f);
		setRequiredParameter("pitchAngle2", 0f);
		setRequiredParameter("rollAngle", 0f);
	}

}
